
/*public class Better {

    public static void fun(Draw draw) {
        draw.draw();
    }

    public static void main(String[] args) {
        fun(new Rectangle());
        fun(new Flower());
        fun(new Draw());
    }
}

class Draw {
    public void draw() {
        System.out.println("画图！");
    }
}

class Rectangle extends Draw {
    @Override
    public void draw() {
        System.out.println("🔺");
    }
}

class Flower extends  Draw {
    @Override
    public void draw() {
        System.out.println("❀");
    }
}

 */


/*interface IShape {
    //成员变量
    public final static int a = 10;
    //成员方法
    abstract public void func1();
    //void func2();
    default void func3() {
        System.out.println("普通方法实现");
    }
    public static void func4() {
        System.out.println("静态方法的实现");
    }
}

class A implements IShape {
    @Override
    public void func1() {
        System.out.println("666");
    }
}

class Animal {
    String name;
    public Animal(String name) {
        this.name = name;
    }
}

interface IRunning {
    public abstract void func1();
}

interface ISwimming {
    public abstract  void func2();
}

class Dog extends Animal implements IRunning, ISwimming {
    public Dog(String name) {
        super(name);
    }

    @Override
    public void func1() {
        System.out.println(this.name + " is running");
    }

    @Override
    public void func2() {
        System.out.println(this.name + " is swimming");
    }

}

public class Better {
    public static void main(String[] args) {
        Dog d = new Dog("66");
        d.func1();
        d.func2();
    }
}





/*
abstract class Draw {
    public int age;
    public String name;

    public void func1() {
        ;
    }
    public static void func2() {
        ;
    }
   public abstract void draw();
}

class Cycle extends Draw {
    @Override
    public void draw() {
        System.out.println("⚪");
    }
}

 */

import java.util.Arrays;
import java.util.Comparator;

class Student implements Comparable<Student>{
    int age;
    double score;
    String name;

    public Student(int age, double score, String name) {
        this.age = age;
        this.score = score;
        this.name = name;
    }

    @Override
    public String toString() {
        return "Student{" +
                "age=" + age +
                ", score=" + score +
                ", name='" + name + '\'' +
                '}';
    }

    @Override
    public int compareTo(Student o) {
        return this.age - o.age;
    }
}

class NameComparator implements Comparator<Student> {

    @Override
    public int compare(Student o1, Student o2) {
        return o1.compareTo(o2);
    }
}

class Better {
    public static void main(String[] args) {
        Student[] stu = new Student[3];
        stu[0] = new Student(16, 66.6,"wnagba");
        stu[1] = new Student(19,11.52,"sb");
        stu[2] = new Student(26, 88.9,"shit");
        Arrays.sort(stu, new NameComparator());
        System.out.println(Arrays.toString(stu));
    }
}


